﻿Public Class HangVe
    Private bushangve As New BUS.HangVe
    Private dtohangve As New DTO.HangVe
    Private bustracuuhv As New BUS.TraCuuHV
    Private dtotracuuhv As New DTO.TraCuuHV

    Private Sub clall()
        lbten.Text = ""
        lbghichu.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        dtohangve.ten = lbten.Text
        dtohangve.ghichu = lbghichu.Text
        If dtohangve.ten = "" Then
            MessageBox.Show("Chưa nhập tên hạng vé!", "Lỗi", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
            Exit Sub
        End If
        If bushangve.chek(lbten.Text) = False Then
            MessageBox.Show("Hạng vé này đã tồn tại!", "Lỗi", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
            Exit Sub
        Else
            bushangve.save(dtohangve)
            MessageBox.Show("Thành công!", "Thông báo", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation)
            clall()
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Hide()
    End Sub

    Private Sub HangVe_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Me.Hide()
        e.Cancel = True
        If Not Main.f_tracuuhv Is Nothing Then
            Main.f_tracuuhv.dghangve.DataSource = bustracuuhv.dtload().Tables(0)
        End If
    End Sub
End Class